package com.fingard.csp.mapper.datasourcefirst.simulate;

import com.fingard.csp.domain.simulate.SimulateRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 模拟规则表数据库操作接口
 *
 * @author fanghh
 * @date 2021.7.20
 * @version v1.0.1
 */
@Mapper
public interface SimulateRuleMapper {
    /**
     * 查找所有规则
     *
     * @return
     */
    @Select("select * from t_simulate_rule")
    List<SimulateRule> findAll();

    /**
     * 按规则ID查找指定规则
     *
     * @param simulateRule
     * @return
     */
    @Select("select * from t_simulate_rule where urid = #{urid} and isactive='1'")
    SimulateRule findByUrid(SimulateRule simulateRule);

    /**
     * 按线路查找该线路下所有的规则
     *
     * @param simulateRule
     * @return
     */
    @Select("select * from t_simulate_rule where bankcode = #{bankcode} and isactive='1'")
    List<SimulateRule> findByBankCode(SimulateRule simulateRule);

    /**
     * 按线路查找该线路下所有规则，并按规则ID获取指定线路的规则ID分组
     *
     * @param simulateRule
     * @return
     */
    @Select("select urid from t_simulate_rule where bankcode = #{bankcode} and isactive='1' group by urid")
    List<String> findRuleGroup(SimulateRule simulateRule);
}